﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum BuffType
{
    Speed,
    JumpForce,
    JumpTimes
}

public class BuffTester : MonoBehaviour
{
    public BuffType buffType = BuffType.Speed;
    public float BuffValue = 1;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if(collision.CompareTag("Player"))
        {
            DoBuff(collision.gameObject);
        }
    }

    private void DoBuff(GameObject gameObject)
    {
        PlayerData pd = gameObject.GetComponent<PlayerData>();
        if(pd == null)
        {
            return;
        }
        switch(buffType)
        {
            case BuffType.Speed:
                pd.MultiplySpeedByRatio(BuffValue);
                break;
            case BuffType.JumpForce:
                pd.MultiplyJumpForceByRatio(BuffValue);
                pd.MultiplyHangingJumpForceByRatio(BuffValue);
                break;
            case BuffType.JumpTimes:
                pd.AddConstantToMaxJumpTime((int)BuffValue);
                break;
        }
    }
}
